package top.tenebrous.yzl.factorys;

import org.springframework.stereotype.Component;
import top.tenebrous.yzl.chain.AbstractJesticChainHandler;
import top.tenebrous.yzl.context.JesticTask;
import top.tenebrous.yzl.context.Response;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description:
 * @Project: jestic-spring-boot
 * @Package: com.zy.tenebrous.jestic.factory
 * @Author: zhangya
 * @CreateTime: 2023-06-29  13:36
 * @Version: 1.0.0
 */
@Component
public class JesticPropertyChainFactory<T extends JesticTask, C extends Response> {

    private final ConcurrentHashMap<String, AbstractJesticChainHandler<T, C>> jesticHandlerMap = new ConcurrentHashMap<>();

    public void register(String taskType, AbstractJesticChainHandler<T, C> handler) {
        jesticHandlerMap.put(taskType, handler);
    }

    public AbstractJesticChainHandler<T, C> getHandler(String taskType) {
        return jesticHandlerMap.get(taskType);
    }

}
